#!/usr/bin/python
#coding:utf-8
#Projeto Advocatus 

import wx

class Senha_Acesso(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(400,200), style=wx.DEFAULT_DIALOG_STYLE)

        # (MUDAR DIRETORIO)
        bmp = wx.Image('C:\Users\Nicollas\Desktop\Advocatus\imagens\pequeno.png',wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        wx.StaticBitmap(self, -1, bmp, (50,20))

        font1 = wx.Font(12, wx.NORMAL, wx.NORMAL, wx.NORMAL)
        nome=wx.StaticText(self, -1, 'Senha:', pos=(100, 100))
        nome.SetFont(font1)

        self.password = wx.TextCtrl(self, -1, '',  (160, 100), (120, -1), style=wx.TE_PASSWORD)

        wx.Button(self, 1, 'Conectar', (130, 140))
        wx.Button(self, 2, 'Sair', (220, 140))
        self.Bind(wx.EVT_BUTTON, self.OnConnect, id=1)
        self.Bind(wx.EVT_BUTTON, self.OnQuit, id=2)

    def OnConnect(self,event):
        #(MUDAR DIRETORIO)
    	arc = open('C:\Users\Nicollas\Desktop\Advocatus\Codigos\password.txt','r')
    	linha = arc.readline()

       	if self.password.GetValue()==linha:
        	self.Destroy()
        	import Advocatus

       	else:
       		self.password.Clear()
       		dlg = wx.MessageDialog(self, 'Senha de Acesso Incorreta!!', 'Advocatus v1.0', wx.OK|wx.ICON_ERROR)
        	dlg.ShowModal()
        	dlg.Destroy()

    def OnQuit(self, event):
        self.Destroy()

class MyApp(wx.App):
    def OnInit(self):
        dia = Senha_Acesso(None, -1, "Advocatus v1.0")
        dia.ShowModal()
        return True

app = MyApp(0)
app.MainLoop()